<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>精选商品推荐管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
	$(document).ready(function() {
		
	});
	function page(n,s){
		$("#pageNo").val(n);
		$("#pageSize").val(s);
		$("#searchForm").submit();
    	return false;
    }
	
	var check_val = [];
	//全选
	function selectAll(n){
		
		if(n.checked){
			check_val = []
			$("input[type=checkbox]").each(function(i,n) {
				if(i>0){
					this.checked = true; 
			        check_val.push(n.value)
				}
	        });  
		}else{
			$("input[type=checkbox]").each(function(i,n) {  
	            this.checked = false; 
	            check_val = []
	        });
		}
	}
	
	//单选
	function check(n){
	
		if(n.checked){
			check_val.push(n.value)
		}else{
			check_val.splice($.inArray(n.value,check_val),1)
		}
	}
	
	function batchAdd(){
		
		if(check_val==null||check_val ==''||check_val==undefined){
			alertx("请选中添加内容信息");
			return false;
		}
		
		var opecontId = $("#opecontId").val();
		
		$.post('${ctx}/mer/operationContentDetail/insertOperaContentDtl',
						{'id':check_val+'','opecontId':opecontId},function(result){
						alertx(result.msg);	
		});
		
	}
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li><a href="${ctx}/mer/operationContentDetail?opecontId=${spu.opecontId }&opecontTitle=${spu.opecontTitle }">精选商品推荐列表</a></li>
		<li class="active"><a href="${ctx}/mer/spu/operationContentDtlList?opecontId=${spu.opecontId }&opecontTitle=${spu.opecontTitle }">精选商品推荐添加</a></li>
	</ul><br/>
	<form:form id="searchForm" modelAttribute="spu" action="${ctx}/mer/spu/operationContentDtlList?opecontId=${spu.opecontId }&opecontTitle=${spu.opecontTitle }" method="post" class="breadcrumb form-search">
		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
		<ul class="ul-form">
			<li><label>商品名称：</label>
				<form:input path="name" htmlEscape="false" maxlength="255" class="input-medium"/>
			</li>
			
			<li><label>商品分类：</label>
				<sys:treeselect id="parent" name="classifyId" value="${spu.classifyId}" labelName="classifyName" labelValue="${spu.classifyName}"
					title="分类" url="/mer/merClassify/treeData" extId="" cssClass="" allowClear="true"/>
			</li>
			<form:input path="opecontId" htmlEscape="false" maxlength="255" class="input-medium" style="display:none"/>
			<li class="btns"><input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/></li>
			<li class="clearfix"></li>
		</ul>
		</br>
		<ul class="ul-form">
			<shiro:hasPermission name="mer:operationContentDetail:edit">
				<li class="btns"><input id="btnBatchAdd" class="btn btn-primary" type="button" onclick="batchAdd()" value="添加"/></li>
			</shiro:hasPermission>
			<li class="clearfix"></li>
		</ul>
	</form:form>
	<sys:message content="${message}"/>
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
		<thead>
			<tr>
				<th><input type="checkbox" name="ck" onclick="selectAll(this)"></th>
				<th>商品名称</th>
				<th>图片</th>
				<th>商品编码</th>
				<th>分类名称</th>
				<th>更新时间</th>
			</tr>
		</thead>
		<tbody>
		<c:forEach items="${page.list}" var="spu">
			<tr>
				<td>
					<input type="checkbox" value ="${spu.id }" onclick="check(this)">
				</td>
				<td>
					${spu.name}
				</td>
				<td style="width:60px;height:60px">
					<img alt="" src="${spu.photoThumb}">
				</td>
				<td>
					${spu.code}
				</td>
				<td>
					${spu.classifyName}
				</td>
				<td>
					<fmt:formatDate value="${spu.updateDate}" pattern="yyyy-MM-dd HH:mm:ss"/>
				</td>
			</tr>
		</c:forEach>
		</tbody>
	</table>
	<div class="pagination">${page}</div>
</body>
</html>